package DAO.TableAttributDAO;

import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import DAO.DAO_Bd;

public abstract class TableAttributDAO_Bd implements TableAttributDAO{
	protected DAO_Bd dao;

	public List<String> getNomTable() throws SQLException {
		List<String> list = new ArrayList<String>();

		DatabaseMetaData md = dao.getCx().getMetaData();
		String[] tab = new String[1];
		tab[0] = "TABLE";
		ResultSet rs = md.getTables(null, md.getUserName(), "%", tab);
		while (rs.next()) 
		{
			if (rs.getString(3).indexOf("==$0")==-1)
				list.add(rs.getString(3));
		}
		return list;
	}
	
	public boolean deleteTable(String table) throws SQLException{
		String requete = "Drop TABLE " + table  ;
		dao.getSt().executeUpdate(requete);
		return true;
	}
}
